home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
swtools
/
trubasic
/
rolldemos
/
demos
/
rgb
/
xdance.tru
< prev
Wrap
Text File
|
1994-08-02
|
3KB
|
158 lines
! True BASIC - Demo for Silicon Graphics
! uses doublebuffering and rgb-mode Gourard shading
! dance of the sugar plum polygons
! NOTE: adjustments for X windows. checks mode after setting it to see
! if doublebuffering is supported. then lowers increment for loops
! since animation is not as smooth and waits after each frame is shown.
CALL tw_wset_size(0,750,750)
call tw_wset_title(0,"xdance")
dim pts2(5,2), clrs2(5)
randomize
set mode "doublebuffer"
ask mode m$
if m$<>"DOUBLEBUFFER" then
let buffers=0
print "doublebuffering not supported"
pause 1
else
let buffers=1
end if
set mode "rgb"
! use whole screen
open #1: screen 0,1,0,1
! set coordinate system
set window -1,1,-1,1
clear
call swapbuffers(1)
set text justify "center","bottom"
let clr=-1
let n=setfont("Courier")
let n=setfontsize(18)
let n=setfontstyle("BoldOblique")
! use polygons with an increasing number of sides
when error in
let sides=2
do
! determine vertices and colors for polygon
let sides=sides+1
call tbgon(sides)
! come forward
if buffers=0 then
let inc=.05
else
let inc=.01
end if
for i=0 to .5 step inc
clear
draw hexagon with scale(i,i)*rotate(i*10)
call swapbuffers(1)
if buffers=0 then call wait
next i
pause 1
! break apart and come together
for i=0 to 1 step inc
clear
draw logo
draw hexagon with scale(.5,.5)*shift(-i,i)
draw hexagon with scale(.5,.5)*shift(i,i)
draw hexagon with scale(.5,.5)*shift(-i,-i)
draw hexagon with scale(.5,.5)*shift(i,-i)
draw hexagon with scale(.5,.5)*shift(-i,i)*rotate(i)
draw hexagon with scale(.5,.5)*shift(i,i)*rotate(i*2)
draw hexagon with scale(.5,.5)*shift(-i,-i)*rotate(i*4)
draw hexagon with scale(.5,.5)*shift(i,-i)*rotate(i*8)
call swapbuffers(1)
if buffers=0 then call wait
next i
for i=1 to -.01 step -inc
clear
draw logo
draw hexagon with scale(.5,.5)*shift(-i,i)
draw hexagon with scale(.5,.5)*shift(i,i)
draw hexagon with scale(.5,.5)*shift(-i,-i)
draw hexagon with scale(.5,.5)*shift(i,-i)
draw hexagon with scale(.5,.5)*shift(-i,i)*rotate(i)
draw hexagon with scale(.5,.5)*shift(i,i)*rotate(i*2)
draw hexagon with scale(.5,.5)*shift(-i,-i)*rotate(i*4)
draw hexagon with scale(.5,.5)*shift(i,-i)*rotate(i*8)
call swapbuffers(1)
if buffers=0 then call wait
next i
pause 1
! retreat
for i=.5 to 0 step -inc
clear
draw hexagon with scale(i,i)*rotate(i*10)
call swapbuffers(1)
if buffers=0 then call wait
next i
loop
use
! print error if it occurs
set mode "text"
print extext$,exline$
end when
PICTURE hexagon
call gshade(pts2,clrs2)
END PICTURE
sub wait
for w=1 to 10000
let tmp=sin(w)*cos(w)
let tmp=tmp*sin(w)*cos(w)
next w
end sub
! determine vertices and colors for a polygon of n sides
sub tbgon(n)
mat redim pts2(n+1,2)
mat redim clrs2(n+1)
when error in
! determine colors to use
let clr=int(rnd*6)
for i=0 to n-1
let x=cos(i*2*pi/n-1)
let y=sin(i*2*pi/n-1)
let pts2(i+1,1)=x
let pts2(i+1,2)=y
let clrs2(i+1)=mod(i,2)+clr
next i
let x=cos(i*2*3.14159/n-1)
let y=sin(i*2*3.14159/n-1)
let pts2(i+1,1)=x
let pts2(i+1,2)=y
let clrs2(i+1)=mod(i,2)+clr
use
set mode "text"
print extext$,exline$
end when
end sub
PICTURE logo
set color clr+1
box area -.23,.23,-.03,.08
set color clr
box area -.22,.22,-.02,.07
set color 15 ! bright white
plot text, at 0,0: "True BASIC"
END PICTURE
get key k
end